<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp '&#160;'>
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:html="http://www.w3.org/1999/xhtml" exclude-result-prefixes="html">
    <xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="/">

<xsl:variable name="x" select="0" />
	<xsl:choose>
		<xsl:when test="Patron/Item">
			<xsl:for-each select="Patron/Item[string-length( DueDate / text() ) > 0]">				
				<tr>
					<xsl:if test="(position() mod 2 = 1)">
						<xsl:attribute name="style">background-color:#E6E6E6</xsl:attribute>
					</xsl:if>
					<xsl:choose>
						<xsl:when test="string-length(FineAmount/text())=0">
							<td>
								<a>
									<xsl:attribute name="href">http://aleph.uea.ac.uk/F?func=direct&amp;local_base=UEA01&amp;doc_number=<xsl:value-of select="ItemID"/></xsl:attribute>
									<xsl:value-of select="Title"/></a>&nbsp;
							</td>
							<td><xsl:value-of select="Author"/>&nbsp;</td>
							<td>
								<xsl:variable name="FormattedDueDate" select="concat(substring(DueDate,9,2),'-',substring(DueDate,6,2),'-',substring(DueDate,1,4))" />
								<xsl:value-of select="$FormattedDueDate" />&nbsp;
							</td>
							<td>&nbsp;</td>
						</xsl:when>
						<xsl:otherwise>
							<td class="warnFont">
								<a>
									<xsl:attribute name="href">http://aleph.uea.ac.uk/F?func=direct&amp;local_base=UEA01&amp;doc_number=<xsl:value-of select="ItemID"/></xsl:attribute>
									<xsl:value-of select="Title"/></a>&nbsp;
								</td>
							<td class="warnFont"><xsl:value-of select="Author"/>&nbsp;</td>
							<td class="warnFont">
								<xsl:variable name="FormattedDueDate" select="concat(substring(DueDate,9,2),'-',substring(DueDate,6,2),'-',substring(DueDate,1,4))" />
								<xsl:value-of select="$FormattedDueDate" />&nbsp;
							</td>	
							<td class="warnFont"><xsl:value-of select="FineAmount"/>&nbsp;</td>
						</xsl:otherwise>
					</xsl:choose>
				</tr>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
</xsl:template>
</xsl:stylesheet>